import axios from 'axios'

// 全局变量
// Vue.prototype.$http = axios

const baseURL = 'http://localhost:8888/api/private/v1/'
axios.defaults.baseURL = baseURL

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    let token = localStorage.getItem('mytoken')
    if (token) {
        config.headers['Authorization'] = token
    }
    // console.log(config)
    return config
}, function (error) {
    return Promise.reject(error);
})


// 登陆验证
export const checkUser = params => {
    return axios.post('login', params).then(res => {
        console.log(res)
        return res.data
    })
}
// 用户列表
export const userList = params => {
    return axios.get('/user', params).then(res => res.data)
}

// 侧边栏权限
export const getMeuList = () => {
    return axios.get('menus').then(res => res.data)
}